package ext;

import util.GetsTablefieldsUtil;

import javax.swing.table.DefaultTableModel;
import java.util.Vector;

public class MainViewTableModel extends DefaultTableModel {



    static StringBuilder tablename=new StringBuilder("Personnel");
    static Vector<String> columns=GetsTablefieldsUtil.getAllcolumns(tablename.toString());


    public static StringBuilder getTablename() {
        return tablename;
    }

    public static void setTablename(StringBuilder tablename) {
        MainViewTableModel.tablename = tablename;
    }

    private MainViewTableModel(){// 单例模式
        super(null,columns);// data,列名
    }
    private static MainViewTableModel mainViewTableModel=new MainViewTableModel();

    public static MainViewTableModel assembleModel(Vector<Vector<Object>> data){
        mainViewTableModel.setDataVector(data,columns);//
        return mainViewTableModel;

    }

    public static void updataModel(Vector<Vector<Object>> data,Vector<String> columns){
        mainViewTableModel.setDataVector(data,columns);

    }
    public static Vector<String> getColumns() {
        return columns;
    }

    public static void setColumns(String table) {
        MainViewTableModel.columns = GetsTablefieldsUtil.getAllcolumns(table);
    }

    @Override
    public boolean isCellEditable(int row, int column) {
        return false;// 表示不可修改单元格里的内容1
    }


}
